import { createHashRouter } from 'react-router-dom'
import { Home } from '@renderer/views/Home'
import { Manager } from '@renderer/views/Manager'
import { Category } from '@renderer/views/Category'
import { Contents } from '@renderer/views/Contents'
import { Content } from '@renderer/views/Content'
import { Welcome } from '@renderer/views/Welcome'
import { SearchSetting } from '@renderer/views/SearchSetting'
import { categoryLoader } from '@renderer/views/Category/loader'
import { categoryAction } from '@renderer/views/Category/action'
import { contentsLoader } from '@renderer/views/Contents/loader'
import { contentsAction } from '@renderer/views/Contents/action'
import { contentLoader } from '@renderer/views/Content/loader'
import { contentAction } from '@renderer/views/Content/action'
import { Setting } from '@renderer/views/Setting'
import type { Router } from '@remix-run/router'

export const router: Router = createHashRouter([
  {
    path: '/',
    element: <Home />,
  },
  {
    path: 'manager',
    element: <Manager />,
    children: [
      {
        path: 'category',
        element: <Category />,
        loader: categoryLoader,
        action: categoryAction,
        children: [
          {
            path: 'contents/:cid?',
            loader: contentsLoader,
            action: contentsAction,
            element: <Contents />,
            children: [
              {
                index: true,
                element: <Welcome />,
              },
              {
                path: 'content/:id',
                loader: contentLoader,
                action: contentAction,
                element: <Content />,
              },
            ],
          },
        ],
      },
      {
        path: 'setting',
        element: <Setting />,
      },
      {
        path: 'search-setting',
        element: <SearchSetting />,
      },
    ],
  },
]);
